package com.bvbot.core.order;

import static com.bvbot.core.Logger.log;

import java.math.BigDecimal;

import com.bvbot.core.session.BalanceResponse;
import com.bvbot.core.session.BvSession;
import com.bvbot.core.session.BvSessionException;
import com.bvbot.core.session.MarketResponse;

public class CheckStateNow {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws BvSessionException {
		CheckStateNow csn = new CheckStateNow();
		csn.displayState();

	}

	private void displayState() throws BvSessionException {
		BvSession session = new BvSession();
		session.start();
		BalanceResponse balance = session.getBalance();
		MarketResponse mr = session.getGoldMarket();
		MarketResponse mrSilver = session.getSilverMarket();
		MarketResponse silverResponse = session.getSilverMarket();
		// silver
		BigDecimal silverBuyPrice = silverResponse.computeHighestBuyPrice();
		BigDecimal silverComission = new BigDecimal("0.92");
		BigDecimal silverPriceEstimateBeforeComission = new BigDecimal(
				balance.getSilverGrams()).multiply(silverBuyPrice).multiply(
				new BigDecimal("0.001"));
		BigDecimal silverPriceEstimate = silverPriceEstimateBeforeComission
				.multiply(silverComission);
		// gold
		BigDecimal goldBuyPrice = mr.computeHighestBuyPrice();
		BigDecimal goldComission = new BigDecimal("0.999");
		BigDecimal goldPriceEstimateBeforeComission = new BigDecimal(
				balance.getGoldGrams()).multiply(goldBuyPrice).multiply(
				new BigDecimal("0.001"));
		BigDecimal goldPriceEstimate = goldPriceEstimateBeforeComission
				.multiply(goldComission);
		// total cash
		BigDecimal allCashEstimate = goldPriceEstimate.add(
				new BigDecimal(balance.getDollars())).add(silverPriceEstimate);
		log("Current gold world price is : " + mr.getMarketPrice()
				+ " $/Kg and silver world price is "
				+ mrSilver.getMarketPrice() + " $/Kg. Current money is "
				+ balance.getDollars() + " $. Current gold is "
				+ balance.getGoldGrams() + " grams and current silver is "
				+ balance.getSilverGrams() + ". Estimated dollar total = "
				+ allCashEstimate);

	}

}
